
# lst =[]
# for i in range(10000):
#     lst.append(i)
# print(lst)

# 列表推导式
lst = [i**2 for i in range(10000)]
# 强制转换成list
lst = list(range(10000))
print(lst)
# 字典推导
# kwargs = {i[0]:i[1] for i in [("name", 'zhangsan'), ("age", 13)]}
# print(kwargs)

# 生成器表达式
gen = (i for i in range(1000))
print(gen, type(gen))

class A:
    def __next__(self):
        return 1

a = A()
print(next(a))
print(next(a))

# 生成器函数
def func():
    for i in range(3):
        yield i
        print(i)
f =func()
next(f)
next(f)
next(f)
